﻿@{
    ViewBag.Title = "贷款记录查询 - 瀚华通";
    ViewBag.Keywords = "瀚华通,瀚华小额贷款,瀚华小贷,瀚华,在线信贷服务";
    ViewBag.Description = "瀚华通-在线信贷服务-贷款记录查询";
}
@section header{
    <link media="screen" href="/css/styleC.css" type="text/css" rel="stylesheet" />
    <script type="text/javascript" src="/Scripts/jquery.validate.min.js"></script>
    <script src="/Scripts/jquery.validate.message.cn.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            jQuery.validator.addMethod("isIdCardNo", function (value, element) {
                return this.optional(element) || isIdCardNo(value);
            }, "请正确输入您的身份证号码");
            //手机号码验证      
            jQuery.validator.addMethod("isMobile", function (value, element) {
                var length = value.length;
                var mobile = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
                return this.optional(element) || (length == 11 && mobile.test(value));
            }, "请正确填写您的手机号码");
        });

        //增加身份证验证
        function isIdCardNo(num) {
            var factorArr = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1);
            var parityBit = new Array("1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2");
            var varArray = new Array();
            var intValue;
            var lngProduct = 0;
            var intCheckDigit;
            var intStrLen = num.length;
            var idNumber = num;
            // initialize
            if ((intStrLen != 15) && (intStrLen != 18)) {
                return false;
            }
            // check and set value
            for (i = 0; i < intStrLen; i++) {
                varArray[i] = idNumber.charAt(i);
                if ((varArray[i] < '0' || varArray[i] > '9') && (i != 17)) {
                    return false;
                } else if (i < 17) {
                    varArray[i] = varArray[i] * factorArr[i];
                }
            }

            if (intStrLen == 18) {
                //check date
                var date8 = idNumber.substring(6, 14);
                if (isDate8(date8) == false) {
                    return false;
                }
                // calculate the sum of the products
                for (i = 0; i < 17; i++) {
                    lngProduct = lngProduct + varArray[i];
                }
                // calculate the check digit
                intCheckDigit = parityBit[lngProduct % 11];
                // check last digit
                if (varArray[17] != intCheckDigit) {
                    return false;
                }
            }
            else {        //length is 15
                //check date
                var date6 = idNumber.substring(6, 12);
                if (isDate6(date6) == false) {
                    return false;
                }
            }
            return true;
        }
        function isDate6(sDate) {
            if (!/^[0-9]{6}$/.test(sDate)) {
                return false;
            }
            var year, month, day;
            year = sDate.substring(0, 4);
            month = sDate.substring(4, 6);
            if (year < 1700 || year > 2500) return false
            if (month < 1 || month > 12) return false
            return true
        }
        /**
        * 判断是否为“YYYYMMDD”式的时期
        *
        */
        function isDate8(sDate) {
            if (!/^[0-9]{8}$/.test(sDate)) {
                return false;
            }
            var year, month, day;
            year = sDate.substring(0, 4);
            month = sDate.substring(4, 6);
            day = sDate.substring(6, 8);
            var iaMonthDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
            if (year < 1700 || year > 2500) return false
            if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) iaMonthDays[1] = 29;
            if (month < 1 || month > 12) return false
            if (day < 1 || day > iaMonthDays[month - 1]) return false
            return true
        }
        $(function () {
            $("#frmQuery").validate();

            $("#txtIdCard").blur(function () {
                //IdCardExist();
            })
            $("#txtPhone").blur(function () {
                //PhoneExist();
            })
        });

        function IdCardExist() {
            $.get("/interface/isidcardexist", { idcard: $("#txtIdCard").val() }, function (data) {
                if (data == 0) {
                    $("#spIdCard").html("系统不存在此身份证号码");
                    return false;
                }
                else {
                    $("#spIdCard").empty();
                    return true;
                }
            });
        }

        function PhoneExist() {
            $.get("/interface/isphoneexist", { phone: $("#txtPhone").val() }, function (data) {
                if (data == 0) {
                    $("#spPhone").html("系统不存在此手机号");
                    return false;
                }
                else {
                    $("#spPhone").empty();
                    return true;
                }
            });
        }

        function VValicate() {
            $.get("/query/VCodeValidate", { vcode: $("#txtVCode").val() }, function (data) {
                if (data == 0) {
                    alert("验证码输入有误或者已过有效期，请重新获取。");
                    return false;
                }
                else {
                    return true;
                }
            })
        }
    </script>
    <style type="text/css">
        table td
        {
            font-size: 12px;
            line-height: 26px;
            padding-left: 14px;
        }
    </style>
}
@section footer{
}
<div id="content">
    <div style="width: 940px; margin: 0 auto; padding-top: 10px;">
        <div class="la_name">
            <h6>
                项目查询</h6>@Html.Hidden("hsmsInterval", ViewData["smsInterval"]); <span><a href="/">返回</a></span></div>
        <div id="nlt1" style="display: block;">
            <div class="c_form c_form_small">
                <form id="frmQuery" action="/query/validate" method="post">
                <table width="98%" border="0" cellspacing="1">
                    <tr>
                        <td width="27%" align="right">
                            身份证号<br />
                        </td>
                        <td width="73%" align="left">
                            <input type="text" name="txtIdCard" id="txtIdCard" class="inputText required isIdCardNo"
                                value="" /><span id="spIdCard" style="color: Red;"></span>
                        </td>
                    </tr>
                    <tr>
                        <td width="27%" align="right">
                            手机号<br />
                        </td>
                        <td width="73%" align="left">
                            <input type="text" name="txtPhone" id="txtPhone" class="inputText required isMobile"
                                value="" />
                            <input type="button" value="获取验证码" id="btnSend" onclick="SendVCode()" />
                            <span id="spPhone" style="color: Red;"></span>
                        </td>
                    </tr>
                    <tr>
                        <td width="27%" align="right">
                            验证码<br />
                        </td>
                        <td width="73%" align="left">
                            <input type="text" name="txtVCode" id="txtVCode" class="inputText required" value="" />
                        </td>
                    </tr>
                    <tr>
                        <td width="27%" align="right">
                            &nbsp;
                        </td>
                        <td width="73%" align="left">
                            <input value="查 询" type="submit" style="width: 80px" />
                        </td>
                    </tr>
                </table>
                </form>
            </div>
        </div>
    </div>
</div>
</div>
<script type="text/javascript">

    function checkPhone() {
        $("#spInfo").empty();
        if ($("#txtPhone").val() == "") {
            $("#spInfo").html("<font color='red'>手机号码不能为空！</font>");
            $("#txtPhone").focus();
            return false;
        }

        if (!$("#txtPhone").val().match(/^1[3|4|5|8][0-9]\d{4,8}$/)) {
            $("#spInfo").html("<font color='red'>手机号码格式不正确！请重新输入！</font>");
            $("#txtPhone").focus();
            return false;
        }
        return true;
    }

    function setDisabledTime(id, time) {
        var btn = $("#" + id);
        var originBtnValue = btn.val();
        btn.fadeIn(1000);
        btn.val(time <= 0 ? "发送验证码" : ("请在" + (time) + "秒内提交"));
        var hander = setInterval(function () {
            if (time <= 0) {
                clearInterval(hander);
                btn.val(originBtnValue);
                btn.removeAttr("disabled");
            } else {
                btn.attr({ "disabled": "disabled" });
                btn.val("请在" + (time--) + "秒内提交");
            }
        }, 1000);
    }

    function SendVCode() {
        if (checkPhone()) {
            $.post('/Interface/SengSmsVCode', { idCard: $("#txtIdCard").val(), mobile: $("#txtPhone").val(), IsAddSession: true },
                    function (d) {
                        //alert(d);                       
                        if (d == 1) {
                            //$("#txtPhone").attr('disabled', true);
                            //$("#btnSend").attr('disabled', true);
                            setDisabledTime("btnSend", $("#hsmsInterval").val());
                            alert("验证码发送成功！");
                        }
                        else if (d == 11) {
                            alert("！");
                        }
                        else if (d == 12) {
                            alert("您接收验证码过于频繁，请稍后再试！");
                        }
                        else if (d == 7) {
                            alert("您接收验证码过于频繁，请稍后再试！");
                        }
                        else {
                            alert("验证码发送失败！");
                        }
                    }, 'text');
        }
    }
    /*
    function loadList() {
    var htmlname = "listDt";
    $("#" + htmlname).load(
    "/Query/GetList",
    {
    idCard: $("#txtIdCard").val(),
    phone: $("#txtPhone").val(),
    vcode: $("#txtVCode").val()
    }, function (responseText, textStatus, XMLHttpRequest) {
    if (responseText) {
    $("#spInfo").Html(responseText);
    }
    });
    $("#detailDt").empty();
    }
    */
</script>
